﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Infrastructure;
using Infrastructure.DataTypes;
namespace RecommenderSystem
{
    public delegate void ScoreSelectEventHandler(string itemID, int rating);
    public partial class UCLmovieDetails : UserControl
    {
        string itemID;

        public event ScoreSelectEventHandler ScoreSelection;
        public UCLmovieDetails()
        {
            InitializeComponent();
            itemID = null;

        }
        public UCLmovieDetails(Item<Discrete> item)
        {
            InitializeComponent();
            itemID = item.ItemID;
            string gn = "Genres : ";
            foreach (KeyValuePair<string, string> data in item.Data_Attributes)
            {
                switch (data.Key)
                {
                    case "title": labelTitle.Text = data.Value;

                        break;
                    case "video_release_date": labelReleaseDate.Text = "Video release date :" + data.Value;
                        break;
                    case "IMDb_URL":
                        break;
                    default:
                        if (gn == "Genres : ")
                        {
                            gn = gn + data.Value.ToString();
                        }
                        else
                        {
                            gn = gn + ", " + data.Value.ToString();
                        }
                        break;
                }
            }
            labelGenres.Text = gn;

        }

        private void starRating1_RatingValueChanged(object sender, ThirstyCrow.WinForms.Controls.RatingChangedEventArgs e)
        {
            if (ScoreSelection != null)
            {
                ScoreSelection(itemID, starRating1.Rating);
            }
        }

    }
}
